home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / tests / place.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  6.8 KB  |  222 lines  |  [TEXT/ALFA]

  1. # This file is a Tcl script to test out the "place" command.  It is
  2. # organized in the standard fashion for Tcl tests.
  3. #
  4. # Copyright (c) 1995 Sun Microsystems, Inc.
  5. #
  6. # See the file "license.terms" for information on usage and redistribution
  7. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  8. #
  9. # SCCS: @(#) place.test 1.6 96/02/16 10:56:01
  10.  
  11. if {[info procs test] != "test"} {
  12.     source defs
  13. }
  14.  
  15. foreach i [winfo children .] {
  16.     destroy $i
  17. }
  18. wm geometry . {}
  19. raise .
  20.  
  21. # XXX - This test file is woefully incomplete.  At present, only a
  22. # few of the features are tested.
  23.  
  24. toplevel .t -width 300 -height 200 -bd 0
  25. wm geom .t +0+0
  26. frame .t.f -width 154 -height 84 -bd 2 -relief raised
  27. place .t.f -x 48 -y 38
  28. frame .t.f2 -width 30 -height 60 -bd 2 -relief raised
  29. update
  30.  
  31. test place-1.1 {Tk_PlaceCmd procedure, "info" option} {
  32.     place .t.f2 -x 0
  33.     place info .t.f2
  34. } {-x 0 -relx 0 -y 0 -rely 0 -width {} -relwidth {} -height {} -relheight {} -anchor nw}
  35. test place-1.2 {Tk_PlaceCmd procedure, "info" option} {
  36.     place .t.f2 -x 1 -y 2 -width 3 -height 4 -relx 0.1 -rely 0.2 \
  37.         -relwidth 0.3 -relheight 0.4 -anchor se -in .t.f  \
  38.         -bordermode outside
  39.     place info .t.f2
  40. } {-x 1 -relx 0.1 -y 2 -rely 0.2 -width 3 -relwidth 0.3 -height 4 -relheight 0.4 -anchor se -bordermode outside -in .t.f}
  41.  
  42. test place-2.1 {ConfigureSlave procedure, -height option} {
  43.     list [catch {place .t.f2 -height abcd} msg] $msg
  44. } {1 {bad screen distance "abcd"}}
  45. test place-2.2 {ConfigureSlave procedure, -height option} {
  46.     place forget .t.f2
  47.     place .t.f2 -in .t.f -height 40
  48.     update
  49.     winfo height .t.f2
  50. } {40}
  51. test place-2.3 {ConfigureSlave procedure, -height option} {
  52.     place forget .t.f2
  53.     place .t.f2 -in .t.f -height 120
  54.     update
  55.     place .t.f2 -height {}
  56.     update
  57.     winfo height .t.f2
  58. } {60}
  59.  
  60. test place-3.1 {ConfigureSlave procedure, -relheight option} {
  61.     list [catch {place .t.f2 -relheight abcd} msg] $msg
  62. } {1 {expected floating-point number but got "abcd"}}
  63. test place-3.2 {ConfigureSlave procedure, -relheight option} {
  64.     place forget .t.f2
  65.     place .t.f2 -in .t.f -relheight .5
  66.     update
  67.     winfo height .t.f2
  68. } {40}
  69. test place-3.3 {ConfigureSlave procedure, -relheight option} {
  70.     place forget .t.f2
  71.     place .t.f2 -in .t.f -relheight .8
  72.     update
  73.     place .t.f2 -relheight {}
  74.     update
  75.     winfo height .t.f2
  76. } {60}
  77.  
  78. test place-4.1 {ConfigureSlave procedure, bad -in options} {
  79.     place forget .t.f2
  80.     list [catch {place .t.f2 -in .t.f2} msg] $msg
  81. } {1 {can't place .t.f2 relative to itself}}
  82.  
  83. test place-5.1 {ConfigureSlave procedure, -relwidth option} {
  84.     list [catch {place .t.f2 -relwidth abcd} msg] $msg
  85. } {1 {expected floating-point number but got "abcd"}}
  86. test place-5.2 {ConfigureSlave procedure, -relwidth option} {
  87.     place forget .t.f2
  88.     place .t.f2 -in .t.f -relwidth .5
  89.     update
  90.     winfo width .t.f2
  91. } {75}
  92. test place-5.3 {ConfigureSlave procedure, -relwidth option} {
  93.     place forget .t.f2
  94.     place .t.f2 -in .t.f -relwidth .8
  95.     update
  96.     place .t.f2 -relwidth {}
  97.     update
  98.     winfo width .t.f2
  99. } {30}
  100.  
  101. test place-6.1 {ConfigureSlave procedure, -width option} {
  102.     list [catch {place .t.f2 -width abcd} msg] $msg
  103. } {1 {bad screen distance "abcd"}}
  104. test place-6.2 {ConfigureSlave procedure, -width option} {
  105.     place forget .t.f2
  106.     place .t.f2 -in .t.f -width 100
  107.     update
  108.     winfo width .t.f2
  109. } {100}
  110. test place-6.3 {ConfigureSlave procedure, -width option} {
  111.     place forget .t.f2
  112.     place .t.f2 -in .t.f -width 120
  113.     update
  114.     place .t.f2 -width {}
  115.     update
  116.     winfo width .t.f2
  117. } {30}
  118.  
  119. test place-7.1 {ReconfigurePlacement procedure, computing position} {
  120.     place forget .t.f2
  121.     place .t.f2 -in .t.f -x -2 -relx .5 -y 3 -rely .4
  122.     update
  123.     winfo geometry .t.f2
  124. } {30x60+123+75}
  125. test place-7.2 {ReconfigurePlacement procedure, position rounding} {
  126.     place forget .t.f2
  127.     place .t.f2 -in .t.f -x -1.4 -y -2.3
  128.     update
  129.     winfo geometry .t.f2
  130. } {30x60+49+38}
  131. test place-7.3 {ReconfigurePlacement procedure, position rounding} {
  132.     place forget .t.f2
  133.     place .t.f2 -in .t.f -x 1.4 -y 2.3
  134.     update
  135.     winfo geometry .t.f2
  136. } {30x60+51+42}
  137. test place-7.4 {ReconfigurePlacement procedure, position rounding} {
  138.     place forget .t.f2
  139.     place .t.f2 -in .t.f -x -1.6 -y -2.7
  140.     update
  141.     winfo geometry .t.f2
  142. } {30x60+48+37}
  143. test place-7.5 {ReconfigurePlacement procedure, position rounding} {
  144.     place forget .t.f2
  145.     place .t.f2 -in .t.f -x 1.6 -y 2.7
  146.     update
  147.     winfo geometry .t.f2
  148. } {30x60+52+43}
  149. test place-7.6 {ReconfigurePlacement procedure, position rounding} {
  150.     frame .t.f3 -width 100 -height 100 -bg #f00000 -bd 0
  151.     place .t.f3 -x 0 -y 0
  152.     raise .t.f2
  153.     place forget .t.f2
  154.     place .t.f2 -in .t.f3 -relx .303 -rely .406 -relwidth .304 -relheight .206
  155.     update
  156.     winfo geometry .t.f2
  157. } {31x20+30+41}
  158. catch {destroy .t.f3}
  159. test place-7.7 {ReconfigurePlacement procedure, computing size} {
  160.     place forget .t.f2
  161.     place .t.f2 -in .t.f -width 120 -height 89
  162.     update
  163.     list [winfo width .t.f2] [winfo height .t.f2]
  164. } {120 89}
  165. test place-7.8 {ReconfigurePlacement procedure, computing size} {
  166.     place forget .t.f2
  167.     place .t.f2 -in .t.f -relwidth .4 -relheight .5
  168.     update
  169.     list [winfo width .t.f2] [winfo height .t.f2]
  170. } {60 40}
  171. test place-7.9 {ReconfigurePlacement procedure, computing size} {
  172.     place forget .t.f2
  173.     place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5
  174.     update
  175.     list [winfo width .t.f2] [winfo height .t.f2]
  176. } {70 36}
  177. test place-7.10 {ReconfigurePlacement procedure, computing size} {
  178.     place forget .t.f2
  179.     place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5
  180.     place .t.f2 -width {} -relwidth {} -height {} -relheight {}
  181.     update
  182.     list [winfo width .t.f2] [winfo height .t.f2]
  183. } {30 60}
  184.  
  185.  
  186. test place-8.1 {MasterStructureProc, mapping and unmapping slaves} {
  187.     place forget .t.f2
  188.     place forget .t.f
  189.     place .t.f2 -relx 1.0 -rely 1.0 -anchor sw
  190.     update
  191.     set result [winfo ismapped .t.f2]
  192.     wm iconify .t
  193.     update
  194.     lappend result [winfo ismapped .t.f2]
  195.     place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw
  196.     update
  197.     lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2]
  198.     wm deiconify .t
  199.     update
  200.     lappend result [winfo ismapped .t.f2]
  201. } {1 0 40 30 0 1}
  202. test place-8.2 {MasterStructureProc, mapping and unmapping slaves} {
  203.     place forget .t.f2
  204.     place forget .t.f
  205.     place .t.f -x 0 -y 0 -width 200 -height 100
  206.     place .t.f2 -in .t.f -relx 1.0 -rely 1.0 -anchor sw -width 50 -height 20
  207.     update
  208.     set result [winfo ismapped .t.f2]
  209.     wm iconify .t
  210.     update
  211.     lappend result [winfo ismapped .t.f2]
  212.     place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw
  213.     update
  214.     lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2]
  215.     wm deiconify .t
  216.     update
  217.     lappend result [winfo ismapped .t.f2]
  218. } {1 0 42 32 0 1}
  219.  
  220. catch {destroy .t}
  221. concat
  222.